<head>
  <style> body { margin: 0; } </style>

  <script type="importmap">{ "imports": {
    "react": "https://esm.sh/react",
    "react-dom": "https://esm.sh/react-dom/client"
  }}</script>

<!--  <script type="module">import * as React from 'react'; window.React = React;</script>-->
<!--  <script src="../../dist/react-globe.gl.js" defer></script>-->
</head>

<body>
<div id="globeViz"></div>

<script src="//unpkg.com/@babel/standalone"></script>
<script type="text/jsx" data-type="module">
  import Globe from 'https://esm.sh/react-globe.gl?external=react';
  import React, { useState, useEffect } from 'react';
  import { createRoot } from 'react-dom';

  const World = () => {
    const [volcanoes, setVolcanoes] = useState([]);

    useEffect(() => {
      // load data
      fetch('../datasets/world_volcanoes.json').then(res => res.json())
        .then(setVolcanoes);
    }, []);

    return <Globe
      globeImageUrl="//cdn.jsdelivr.net/npm/three-globe/example/img/earth-blue-marble.jpg"
      heatmapsData={[volcanoes]}
      heatmapPointLat="lat"
      heatmapPointLng="lon"
      heatmapPointWeight={d => d.elevation * 5e-5}
      heatmapTopAltitude={0.2}
      heatmapBandwidth={1.35}
      heatmapColorSaturation={3.2}
      enablePointerInteraction={false}
    />;
  };

  createRoot(document.getElementById('globeViz'))
    .render(<World />);
</script>
</body>